package com.jindy.module.machineCostView.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.machineCostView.domain.MachineCostView;
import com.jindy.module.machineCostView.service.IMachineCostViewService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * VIEWController
 * 
 * @author jindy
 * @date 2023-06-05
 */
@RestController
@RequestMapping("/module/machineCostView")
public class MachineCostViewController extends BaseController
{
    @Autowired
    private IMachineCostViewService machineCostViewService;

    /**
     * 查询VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('module:machineCostView:list')")
    @GetMapping("/list")
    public TableDataInfo list(MachineCostView machineCostView)
    {
        startPage();
        List<MachineCostView> list = machineCostViewService.selectMachineCostViewList(machineCostView);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('module:machineCostView:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MachineCostView machineCostView)
    {
        List<MachineCostView> list = machineCostViewService.selectMachineCostViewList(machineCostView);
        ExcelUtil<MachineCostView> util = new ExcelUtil<MachineCostView>(MachineCostView.class);
        util.exportExcel(response, list, "VIEW数据");
    }

    /**
     * 获取VIEW详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:machineCostView:query')")
    @GetMapping(value = "/{number}")
    public AjaxResult getInfo(@PathVariable("number") String number)
    {
        return AjaxResult.success(machineCostViewService.selectMachineCostViewByNumber(number));
    }

    /**
     * 新增VIEW
     */
    @PreAuthorize("@ss.hasPermi('module:machineCostView:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MachineCostView machineCostView)
    {
        return toAjax(machineCostViewService.insertMachineCostView(machineCostView));
    }

    /**
     * 修改VIEW
     */
    @PreAuthorize("@ss.hasPermi('module:machineCostView:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MachineCostView machineCostView)
    {
        return toAjax(machineCostViewService.updateMachineCostView(machineCostView));
    }

    /**
     * 删除VIEW
     */
    @PreAuthorize("@ss.hasPermi('module:machineCostView:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{numbers}")
    public AjaxResult remove(@PathVariable String[] numbers)
    {
        return toAjax(machineCostViewService.deleteMachineCostViewByNumbers(numbers));
    }
}
